package com.sto.stoapp.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.http.response.download.info.OrderRecordInfo;

public class SelectOrderAdapter extends BaseAdapter {

	private List<OrderRecordInfo> courierList;
	
	private Context context;

	/**
	 * 构造函数
	 * 
	 * @param context
	 * @param courierList
	 */
	public SelectOrderAdapter(Context context,
			List<OrderRecordInfo> courierList) {
		this.courierList = courierList;
		this.context = context;
	}
	
	@Override
	public int getCount() {
		
		return courierList == null ? 0 : courierList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return courierList.get(arg0);
	}	

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder;
		if (view == null) {
			holder = new Holder();
			view = LayoutInflater.from(context).inflate(
					R.layout.sto_listview_head, null);
			holder.sequence_number = (TextView) view
					.findViewById(R.id.sequence_number);
			holder.courier_status = (TextView) view
					.findViewById(R.id.courier_status);
			holder.courier_code = (TextView) view
					.findViewById(R.id.courier_code);
			view.setTag(holder);
		} else {
			holder = (Holder) view.getTag();
		}
		OrderRecordInfo info=(OrderRecordInfo) getItem(position);
		
		holder.courier_code.setText(info.oderNo);
		holder.courier_status.setText("未");
		if("1".equals(info.urgeTag)){
			holder.courier_status.setText("催");
		}
		holder.sequence_number.setText((position+1) +"");
		return view;
	}

	class Holder {
		TextView sequence_number;
		TextView courier_status;
		TextView courier_code;
	}
	
}
